/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vcms.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.vportal.portlet.vcms.model.VcmsDiscussion;
import com.vportal.portlet.vcms.model.VcmsDiscussionModel;
import com.vportal.portlet.vcms.model.VcmsDiscussionSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the VcmsDiscussion service. Represents a row in the &quot;VcmsDiscussion&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vcms.model.VcmsDiscussionModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VcmsDiscussionImpl}.
 * </p>
 *
 * @author hai
 * @see VcmsDiscussionImpl
 * @see com.vportal.portlet.vcms.model.VcmsDiscussion
 * @see com.vportal.portlet.vcms.model.VcmsDiscussionModel
 * @generated
 */
@JSON(strict = true)
public class VcmsDiscussionModelImpl extends BaseModelImpl<VcmsDiscussion>
	implements VcmsDiscussionModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a vcms discussion model instance should use the {@link com.vportal.portlet.vcms.model.VcmsDiscussion} interface instead.
	 */
	public static final String TABLE_NAME = "VcmsDiscussion";
	public static final Object[][] TABLE_COLUMNS = {
			{ "discussionId", Types.VARCHAR },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "visitorName", Types.VARCHAR },
			{ "visitorEmail", Types.VARCHAR },
			{ "visitorPhone", Types.VARCHAR },
			{ "postedDate", Types.TIMESTAMP },
			{ "approved", Types.BOOLEAN },
			{ "approvedByUser", Types.VARCHAR },
			{ "approvedDate", Types.TIMESTAMP },
			{ "articleId", Types.VARCHAR },
			{ "title", Types.VARCHAR },
			{ "content", Types.VARCHAR },
			{ "language", Types.VARCHAR },
			{ "hasAttachment", Types.BOOLEAN }
		};
	public static final String TABLE_SQL_CREATE = "create table VcmsDiscussion (discussionId VARCHAR(75) not null primary key,groupId LONG,companyId LONG,visitorName VARCHAR(200) null,visitorEmail VARCHAR(200) null,visitorPhone VARCHAR(200) null,postedDate DATE null,approved BOOLEAN,approvedByUser VARCHAR(75) null,approvedDate DATE null,articleId VARCHAR(75) null,title VARCHAR(500) null,content TEXT null,language VARCHAR(75) null,hasAttachment BOOLEAN)";
	public static final String TABLE_SQL_DROP = "drop table VcmsDiscussion";
	public static final String ORDER_BY_JPQL = " ORDER BY vcmsDiscussion.postedDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY VcmsDiscussion.postedDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vcms.model.VcmsDiscussion"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vcms.model.VcmsDiscussion"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vcms.model.VcmsDiscussion"),
			true);
	public static long APPROVED_COLUMN_BITMASK = 1L;
	public static long ARTICLEID_COLUMN_BITMASK = 2L;
	public static long GROUPID_COLUMN_BITMASK = 4L;
	public static long LANGUAGE_COLUMN_BITMASK = 8L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VcmsDiscussion toModel(VcmsDiscussionSoap soapModel) {
		VcmsDiscussion model = new VcmsDiscussionImpl();

		model.setDiscussionId(soapModel.getDiscussionId());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setVisitorName(soapModel.getVisitorName());
		model.setVisitorEmail(soapModel.getVisitorEmail());
		model.setVisitorPhone(soapModel.getVisitorPhone());
		model.setPostedDate(soapModel.getPostedDate());
		model.setApproved(soapModel.getApproved());
		model.setApprovedByUser(soapModel.getApprovedByUser());
		model.setApprovedDate(soapModel.getApprovedDate());
		model.setArticleId(soapModel.getArticleId());
		model.setTitle(soapModel.getTitle());
		model.setContent(soapModel.getContent());
		model.setLanguage(soapModel.getLanguage());
		model.setHasAttachment(soapModel.getHasAttachment());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VcmsDiscussion> toModels(VcmsDiscussionSoap[] soapModels) {
		List<VcmsDiscussion> models = new ArrayList<VcmsDiscussion>(soapModels.length);

		for (VcmsDiscussionSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vcms.model.VcmsDiscussion"));

	public VcmsDiscussionModelImpl() {
	}

	public String getPrimaryKey() {
		return _discussionId;
	}

	public void setPrimaryKey(String primaryKey) {
		setDiscussionId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _discussionId;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return VcmsDiscussion.class;
	}

	public String getModelClassName() {
		return VcmsDiscussion.class.getName();
	}

	@JSON
	public String getDiscussionId() {
		if (_discussionId == null) {
			return StringPool.BLANK;
		}
		else {
			return _discussionId;
		}
	}

	public void setDiscussionId(String discussionId) {
		_discussionId = discussionId;
	}

	@JSON
	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public String getVisitorName() {
		if (_visitorName == null) {
			return StringPool.BLANK;
		}
		else {
			return _visitorName;
		}
	}

	public void setVisitorName(String visitorName) {
		_visitorName = visitorName;
	}

	@JSON
	public String getVisitorEmail() {
		if (_visitorEmail == null) {
			return StringPool.BLANK;
		}
		else {
			return _visitorEmail;
		}
	}

	public void setVisitorEmail(String visitorEmail) {
		_visitorEmail = visitorEmail;
	}

	@JSON
	public String getVisitorPhone() {
		if (_visitorPhone == null) {
			return StringPool.BLANK;
		}
		else {
			return _visitorPhone;
		}
	}

	public void setVisitorPhone(String visitorPhone) {
		_visitorPhone = visitorPhone;
	}

	@JSON
	public Date getPostedDate() {
		return _postedDate;
	}

	public void setPostedDate(Date postedDate) {
		_columnBitmask = -1L;

		_postedDate = postedDate;
	}

	@JSON
	public boolean getApproved() {
		return _approved;
	}

	public boolean isApproved() {
		return _approved;
	}

	public void setApproved(boolean approved) {
		_columnBitmask |= APPROVED_COLUMN_BITMASK;

		if (!_setOriginalApproved) {
			_setOriginalApproved = true;

			_originalApproved = _approved;
		}

		_approved = approved;
	}

	public boolean getOriginalApproved() {
		return _originalApproved;
	}

	@JSON
	public String getApprovedByUser() {
		if (_approvedByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _approvedByUser;
		}
	}

	public void setApprovedByUser(String approvedByUser) {
		_approvedByUser = approvedByUser;
	}

	@JSON
	public Date getApprovedDate() {
		return _approvedDate;
	}

	public void setApprovedDate(Date approvedDate) {
		_approvedDate = approvedDate;
	}

	@JSON
	public String getArticleId() {
		if (_articleId == null) {
			return StringPool.BLANK;
		}
		else {
			return _articleId;
		}
	}

	public void setArticleId(String articleId) {
		_columnBitmask |= ARTICLEID_COLUMN_BITMASK;

		if (_originalArticleId == null) {
			_originalArticleId = _articleId;
		}

		_articleId = articleId;
	}

	public String getOriginalArticleId() {
		return GetterUtil.getString(_originalArticleId);
	}

	@JSON
	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	public void setTitle(String title) {
		_title = title;
	}

	@JSON
	public String getContent() {
		if (_content == null) {
			return StringPool.BLANK;
		}
		else {
			return _content;
		}
	}

	public void setContent(String content) {
		_content = content;
	}

	@JSON
	public String getLanguage() {
		if (_language == null) {
			return StringPool.BLANK;
		}
		else {
			return _language;
		}
	}

	public void setLanguage(String language) {
		_columnBitmask |= LANGUAGE_COLUMN_BITMASK;

		if (_originalLanguage == null) {
			_originalLanguage = _language;
		}

		_language = language;
	}

	public String getOriginalLanguage() {
		return GetterUtil.getString(_originalLanguage);
	}

	@JSON
	public boolean getHasAttachment() {
		return _hasAttachment;
	}

	public boolean isHasAttachment() {
		return _hasAttachment;
	}

	public void setHasAttachment(boolean hasAttachment) {
		_hasAttachment = hasAttachment;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VcmsDiscussion toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VcmsDiscussion)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		VcmsDiscussionImpl vcmsDiscussionImpl = new VcmsDiscussionImpl();

		vcmsDiscussionImpl.setDiscussionId(getDiscussionId());
		vcmsDiscussionImpl.setGroupId(getGroupId());
		vcmsDiscussionImpl.setCompanyId(getCompanyId());
		vcmsDiscussionImpl.setVisitorName(getVisitorName());
		vcmsDiscussionImpl.setVisitorEmail(getVisitorEmail());
		vcmsDiscussionImpl.setVisitorPhone(getVisitorPhone());
		vcmsDiscussionImpl.setPostedDate(getPostedDate());
		vcmsDiscussionImpl.setApproved(getApproved());
		vcmsDiscussionImpl.setApprovedByUser(getApprovedByUser());
		vcmsDiscussionImpl.setApprovedDate(getApprovedDate());
		vcmsDiscussionImpl.setArticleId(getArticleId());
		vcmsDiscussionImpl.setTitle(getTitle());
		vcmsDiscussionImpl.setContent(getContent());
		vcmsDiscussionImpl.setLanguage(getLanguage());
		vcmsDiscussionImpl.setHasAttachment(getHasAttachment());

		vcmsDiscussionImpl.resetOriginalValues();

		return vcmsDiscussionImpl;
	}

	public int compareTo(VcmsDiscussion vcmsDiscussion) {
		int value = 0;

		value = DateUtil.compareTo(getPostedDate(),
				vcmsDiscussion.getPostedDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VcmsDiscussion vcmsDiscussion = null;

		try {
			vcmsDiscussion = (VcmsDiscussion)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		String primaryKey = vcmsDiscussion.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
		VcmsDiscussionModelImpl vcmsDiscussionModelImpl = this;

		vcmsDiscussionModelImpl._originalGroupId = vcmsDiscussionModelImpl._groupId;

		vcmsDiscussionModelImpl._setOriginalGroupId = false;

		vcmsDiscussionModelImpl._originalApproved = vcmsDiscussionModelImpl._approved;

		vcmsDiscussionModelImpl._setOriginalApproved = false;

		vcmsDiscussionModelImpl._originalArticleId = vcmsDiscussionModelImpl._articleId;

		vcmsDiscussionModelImpl._originalLanguage = vcmsDiscussionModelImpl._language;

		vcmsDiscussionModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VcmsDiscussion> toCacheModel() {
		VcmsDiscussionCacheModel vcmsDiscussionCacheModel = new VcmsDiscussionCacheModel();

		vcmsDiscussionCacheModel.discussionId = getDiscussionId();

		String discussionId = vcmsDiscussionCacheModel.discussionId;

		if ((discussionId != null) && (discussionId.length() == 0)) {
			vcmsDiscussionCacheModel.discussionId = null;
		}

		vcmsDiscussionCacheModel.groupId = getGroupId();

		vcmsDiscussionCacheModel.companyId = getCompanyId();

		vcmsDiscussionCacheModel.visitorName = getVisitorName();

		String visitorName = vcmsDiscussionCacheModel.visitorName;

		if ((visitorName != null) && (visitorName.length() == 0)) {
			vcmsDiscussionCacheModel.visitorName = null;
		}

		vcmsDiscussionCacheModel.visitorEmail = getVisitorEmail();

		String visitorEmail = vcmsDiscussionCacheModel.visitorEmail;

		if ((visitorEmail != null) && (visitorEmail.length() == 0)) {
			vcmsDiscussionCacheModel.visitorEmail = null;
		}

		vcmsDiscussionCacheModel.visitorPhone = getVisitorPhone();

		String visitorPhone = vcmsDiscussionCacheModel.visitorPhone;

		if ((visitorPhone != null) && (visitorPhone.length() == 0)) {
			vcmsDiscussionCacheModel.visitorPhone = null;
		}

		Date postedDate = getPostedDate();

		if (postedDate != null) {
			vcmsDiscussionCacheModel.postedDate = postedDate.getTime();
		}
		else {
			vcmsDiscussionCacheModel.postedDate = Long.MIN_VALUE;
		}

		vcmsDiscussionCacheModel.approved = getApproved();

		vcmsDiscussionCacheModel.approvedByUser = getApprovedByUser();

		String approvedByUser = vcmsDiscussionCacheModel.approvedByUser;

		if ((approvedByUser != null) && (approvedByUser.length() == 0)) {
			vcmsDiscussionCacheModel.approvedByUser = null;
		}

		Date approvedDate = getApprovedDate();

		if (approvedDate != null) {
			vcmsDiscussionCacheModel.approvedDate = approvedDate.getTime();
		}
		else {
			vcmsDiscussionCacheModel.approvedDate = Long.MIN_VALUE;
		}

		vcmsDiscussionCacheModel.articleId = getArticleId();

		String articleId = vcmsDiscussionCacheModel.articleId;

		if ((articleId != null) && (articleId.length() == 0)) {
			vcmsDiscussionCacheModel.articleId = null;
		}

		vcmsDiscussionCacheModel.title = getTitle();

		String title = vcmsDiscussionCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			vcmsDiscussionCacheModel.title = null;
		}

		vcmsDiscussionCacheModel.content = getContent();

		String content = vcmsDiscussionCacheModel.content;

		if ((content != null) && (content.length() == 0)) {
			vcmsDiscussionCacheModel.content = null;
		}

		vcmsDiscussionCacheModel.language = getLanguage();

		String language = vcmsDiscussionCacheModel.language;

		if ((language != null) && (language.length() == 0)) {
			vcmsDiscussionCacheModel.language = null;
		}

		vcmsDiscussionCacheModel.hasAttachment = getHasAttachment();

		return vcmsDiscussionCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(31);

		sb.append("{discussionId=");
		sb.append(getDiscussionId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", visitorName=");
		sb.append(getVisitorName());
		sb.append(", visitorEmail=");
		sb.append(getVisitorEmail());
		sb.append(", visitorPhone=");
		sb.append(getVisitorPhone());
		sb.append(", postedDate=");
		sb.append(getPostedDate());
		sb.append(", approved=");
		sb.append(getApproved());
		sb.append(", approvedByUser=");
		sb.append(getApprovedByUser());
		sb.append(", approvedDate=");
		sb.append(getApprovedDate());
		sb.append(", articleId=");
		sb.append(getArticleId());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", content=");
		sb.append(getContent());
		sb.append(", language=");
		sb.append(getLanguage());
		sb.append(", hasAttachment=");
		sb.append(getHasAttachment());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(49);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vcms.model.VcmsDiscussion");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>discussionId</column-name><column-value><![CDATA[");
		sb.append(getDiscussionId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>visitorName</column-name><column-value><![CDATA[");
		sb.append(getVisitorName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>visitorEmail</column-name><column-value><![CDATA[");
		sb.append(getVisitorEmail());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>visitorPhone</column-name><column-value><![CDATA[");
		sb.append(getVisitorPhone());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>postedDate</column-name><column-value><![CDATA[");
		sb.append(getPostedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>approved</column-name><column-value><![CDATA[");
		sb.append(getApproved());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>approvedByUser</column-name><column-value><![CDATA[");
		sb.append(getApprovedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>approvedDate</column-name><column-value><![CDATA[");
		sb.append(getApprovedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>articleId</column-name><column-value><![CDATA[");
		sb.append(getArticleId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>content</column-name><column-value><![CDATA[");
		sb.append(getContent());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>language</column-name><column-value><![CDATA[");
		sb.append(getLanguage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>hasAttachment</column-name><column-value><![CDATA[");
		sb.append(getHasAttachment());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VcmsDiscussion.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VcmsDiscussion.class
		};
	private String _discussionId;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _companyId;
	private String _visitorName;
	private String _visitorEmail;
	private String _visitorPhone;
	private Date _postedDate;
	private boolean _approved;
	private boolean _originalApproved;
	private boolean _setOriginalApproved;
	private String _approvedByUser;
	private Date _approvedDate;
	private String _articleId;
	private String _originalArticleId;
	private String _title;
	private String _content;
	private String _language;
	private String _originalLanguage;
	private boolean _hasAttachment;
	private long _columnBitmask;
	private VcmsDiscussion _escapedModelProxy;
}